package com.akk.module.avs.service;

import com.akk.module.avs.entity.AvsYbCardRaider;
import com.akk.module.avs.entity.AvsYbCardRaiderExample;
import com.akk.module.avs.mapper.AvsYbCardRaiderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class AvsYbCardRaiderService {

    @Autowired
    private AvsYbCardRaiderExample cardRaiderExample;

    @Autowired
    private AvsYbCardRaiderMapper cardRaiderMapper;

    public List<AvsYbCardRaider> findByParams(Map params){
        cardRaiderExample.clear();
        AvsYbCardRaiderExample.Criteria criteria = cardRaiderExample.createCriteria();
        if (params.containsKey("appId"))
            criteria.andAppIdEqualTo(params.get("appId").toString());
        return cardRaiderMapper.selectByExample(cardRaiderExample);
    }

    public AvsYbCardRaider findById(Long raiderId){
        return cardRaiderMapper.selectByPrimaryKey(raiderId);
    }

    public void save(AvsYbCardRaider raider){
        cardRaiderMapper.insert(raider);
    }

    public void del(Long raiderId){
        cardRaiderMapper.deleteByPrimaryKey(raiderId);
    }

    public void update(AvsYbCardRaider raider){
        cardRaiderMapper.updateByPrimaryKey(raider);
    }

}
